package org.example.database.Mapper;

import org.apache.ibatis.annotations.*;
import org.example.database.entity.Advice;

@Mapper
public interface AdviceMapper {
    /**
     * 插入建议信息
     * @param advice 建议信息
     * @return 影响行数
     */
    @Insert("INSERT INTO advice (resumeId, result, integrityScore, professionalScore, logicScore, amendingAdvice) " +
            "VALUES (#{resumeId}, #{result}, #{integrityScore}, #{professionalScore}, #{logicScore}, #{amendingAdvice})")
    @Options(useGeneratedKeys = true, keyProperty = "adviceId")
    int insert(Advice advice);

    /**
     * 根据简历ID查询建议
     * @param resumeId 简历ID
     * @return 建议信息
     */
    @Select("SELECT * FROM advice WHERE resumeId = #{resumeId}")
    Advice selectByResumeId(Integer resumeId);

    /**
     * 更新建议信息
     * @param advice 建议信息
     * @return 影响行数
     */
    @Update("UPDATE advice SET result = #{result}, integrityScore = #{integrityScore}, " +
            "professionalScore = #{professionalScore}, logicScore = #{logicScore}, " +
            "amendingAdvice = #{amendingAdvice} WHERE adviceId = #{adviceId}")
    int update(Advice advice);

    /**
     * 删除建议
     * @param adviceId 建议ID
     * @return 影响行数
     */
    @Delete("DELETE FROM advice WHERE adviceId = #{adviceId}")
    int deleteById(Integer adviceId);
}
